Skip to content

🌱 Adopt new(x) over ptr.To(x) and re-enable newexpr lint#3489

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
kunalmemane:fix-modernize-lint
Mar 31, 2026
Merged

🌱 Adopt new(x) over ptr.To(x) and re-enable newexpr lint#3489
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
kunalmemane:fix-modernize-lint

Conversation

@kunalmemane
Copy link
Copy Markdown
Contributor

With Go 1.26, the built-in new(x) can take a value expression and return a pointer to it, making ptr.To(x) from k8s.io/utils/ptr redundant. The newexpr modernize rule was temporarily disabled in .golangci.yml to unblock the v0.36.0-beta.0 dependency bump.

This commit completes the follow-up work : #3488

  • Replace all ~131 occurrences of ptr.To(x) with new(x) across the codebase, including type-parameterized variants like ptr.To[int64](x) which become new(int64(x))
  • Remove the newexpr entry from modernize.disable in .golangci.yml
  • Drop the k8s.io/utils/ptr import from 29 files that no longer use it
  • Update code examples in designs/warmreplicas.md and godoc comments
  • Fix two pre-existing modernize lint issues (stringsbuilder, atomic) to keep golangci-lint fully clean

Replace all ptr.To(x) calls with the Go 1.26 built-in new(x), remove
the newexpr suppression from .golangci.yml, and drop unused
k8s.io/utils/ptr imports. Also fix two pre-existing modernize lint
issues (stringsbuilder, atomic).

Signed-off-by: Kunal Memane <kmemane@redhat.com>
@k8s-ci-robot k8s-ci-robot requested review from inteon and vincepri March 31, 2026 16:34
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 31, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @kunalmemane. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 31, 2026
@alvaroaleman
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 31, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 31, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 7f1f67ce3ab3dc1125e20f772491598fbcfee4e1

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, kunalmemane

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2026
@k8s-ci-robot k8s-ci-robot merged commit bce0ec7 into kubernetes-sigs:main Mar 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants